<!DOCTYPE html>
<html>
    
    <head>
       <meta charset="UTF-8">
        {include="style"}
		{include="edit"}
		
    </head>
    
    <body>
	 <div class="x-nav">
            <span class="layui-breadcrumb">
              <a><cite>首页</cite></a>
              <a><cite>扩展管理</cite></a>
             
			 <a><cite>新增轮播图</cite></a>
            </span>
            <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"  href="javascript:location.replace(location.href);" title="刷新"><i class="iconfont" style="line-height:30px">&#xe6aa;</i></a>
        </div>
        <div class="x-body">
            <form class="layui-form layui-form-pane" >
			<input type="hidden" name="go" value="1" />
			
			<div class="layui-tab">
			  <ul class="layui-tab-title">
				<li class="layui-this">基本信息</li>
				<li>扩展信息</li>
				
			  </ul>
			  <div class="layui-tab-content">
				<div class="layui-tab-item layui-show">
				 <div class="layui-form-item">
                    <label for="title" class="layui-form-label">
                        <span class="x-red">*</span>标题
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="title" value="" style="width:500px;" name="title" required="" lay-verify="required"
                        autocomplete="off" class="layui-input">
                    </div>
                </div>
				<div class="layui-form-item">
                    <label for="tid" class="layui-form-label">
                        <span class="x-red">*</span>所属分类
                    </label>
                    <div class="layui-input-inline">
						<select name="tid" lay-filter="tid" lay-search="" id="tid" >
						<option value="0">选择栏目</option>
					   {foreach $collect_type as $v}
					   <option {if($tid==$v['id'])}selected{/if}  value="{$v['id']}">{$v['name']}</option>
					   {/foreach}
					   </select>
                    </div>
                </div>
				 
				<div class="layui-form-item">
                    <label for="litpic" class="layui-form-label">
						<span class="x-red">*</span>图片  
                    </label>
                    
					<div class="layui-input-inline">
						<input name="litpic" placeholder="上传图片" type="text" class="layui-input" id="litpic"  value="" />
					</div>
					<div class="layui-input-inline">
						<button class="layui-btn layui-btn-primary" id="litpic_upload" type="button" >选择图片</button>
					</div>
					<div class="layui-input-inline">
						<img id="litpic_img" class="img-responsive img-thumbnail" style="max-width: 200px;" src="" onerror="javascipt:this.src='{__Tpl_style__}/style/images/nopic.jpg'; this.title='图片未找到';this.onerror=''">
						<button type="button" onclick="deleteImage(this)" class="layui-btn layui-btn-sm layui-btn-radius layui-btn-danger " title="删除这张图片" >删除</button>
					</div>
                </div>
				
				
				<div class="layui-form-item">
                    <label for="h" class="layui-form-label">
                        <span class="x-red"></span>图片高
                    </label>
                    <div class="layui-input-inline">
                        <input type="text"  placeholder="0表示不限制" value="0" style="width:500px;" name="h" 
                        autocomplete="off" class="layui-input">
                    </div>
                </div>
				<div class="layui-form-item">
                    <label for="w" class="layui-form-label">
                        <span class="x-red"></span>图片宽
                    </label>
                    <div class="layui-input-inline">
                        <input type="text"  placeholder="0表示不限制" value="0" style="width:500px;" name="w" 
                        autocomplete="off" class="layui-input">
                    </div>
                </div>
				
				 <div class="layui-form-item">
                    <label for="url" class="layui-form-label">
                        <span class="x-red"></span>跳转链接
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="url" placeholder="不填请留空" value="" style="width:500px;" name="url" 
                        autocomplete="off" class="layui-input">
                    </div>
                </div>
				<div class="layui-form-item layui-form-text">
                        <label for="description" class="layui-form-label">
                            <span class="x-red"></span>简介
                        </label>
                        <div class="layui-input-block">
                            <textarea  name="description" class="layui-textarea"></textarea>
                        </div>
                </div>
			
				<div class="layui-form-item">
                    <label for="orders" class="layui-form-label">
                        <span class="x-red"></span>排序
                    </label>
                    <div class="layui-input-inline">
                        <input type="number" id="orders" value="0" name="orders" 
                        autocomplete="off" class="layui-input">
                    </div>
					 <div class="layui-form-mid layui-word-aux">
					  数字越大越靠前
				  </div>
					
                </div>
				<div class="layui-form-item" pane>
                    <label for="isshow" class="layui-form-label">
                        <span class="x-red"></span>是否显示
                    </label>
                    <div class="layui-input-inline">
                        <input type="radio" name="isshow" value="0" title="不显示">
						<input type="radio" name="isshow" value="1" title="显示" checked>
                    </div>
					 
					
                </div>
				
				 <div class="layui-form-item">
                    <label for="addtime" class="layui-form-label">
                        <span class="x-red"></span>添加时间
                    </label>
                    <div class="layui-input-inline">
                      <input class="layui-input" value="{fun date('Y-m-d H:i:s')}" name="addtime" placeholder="文件日期" id="LAY_demorange_s">
                    </div>
                   
                </div>
				
				{if($webconf['isrelative']==1)}
				<span id="ext_fields"></span>
				{/if}
				
				
		<!--end tab1-->		
				</div>
				<div class="layui-tab-item">
				
				{if($webconf['isrelative']==0)}
				<span id="ext_fields"></span>
				{/if}
				
				
				</div>
				
			  </div>
			</div>
						
               
                
                <div class="layui-form-item"   style="text-align:center;">
                    
                     <button  class="layui-btn" lay-filter="save" lay-submit="">
                        保存
                    </button>
                </div>
            </form>
        </div>
		<br/>
		<br/>
		<br/>
		<br/>
		<br/>
		<br/>
		<br/>
		<br/>
		<br/>
      
        <script>
		{include="fields"}
		function deleteImage(elm){
			$(elm).prev().attr("src", "{__Tpl_style__}/style/images/nopic.jpg");
			$('#litpic').val("");
		}
            layui.use(['laydate','form','layer','upload'], function(){
                $ = layui.jquery;
              var form = layui.form
              ,layer = layui.layer;
			  laydate = layui.laydate;
			 
			  laydate.render({
				elem: '#LAY_demorange_s', //指定元素
				type:'datetime'
			  });
			  var upload = layui.upload;
			  
             //图片上传接口
              upload.render({
			    elem: '#litpic_upload',
                url: "{fun U('Common/uploads')}" //上传接口
                ,data:{tid:function(){ return $("#tid").val();},molds:'collect'}
                ,done: function(res){ //上传成功后的回调
                 
					if(res.code==0){
						 $('#litpic_img').attr('src',res.url);
						 $('#litpic').val(res.url);
					}else{
						 layer.alert(res.error, {icon: 5});
					}
                 
                }
              });
			  
			  
			    //监听提交
              form.on('submit(save)', function(data){
				$.post("{__APP_URL__}/Collect/addcollect.html",data.field,function(r){
					var r = JSON.parse(r);
					if(r.code==0){
					
						
						layer.confirm(r.msg, {
						  btn: ['返回','确定'] //按钮
						}, function(){
						
							{if($webconf['admintpl']=='tpl')}
							window.location.href="{fun U('Collect/index')}";
							{else}
							parent.location.reload();
							parent.layer.close(index);
							{/if}
						
						  
						}, function(){
						   window.location.href=r.url;
						});
						
					
					}else{
						layer.alert(r.msg, {icon: 5});
					}
				});
				
               
                return false;
              });
			  
				get_fields(0);
            
			
		
			
           
              
              
            });
        </script>
      
    </body>

</html>